package com.jin.lazytool.customevent;

import com.jin.lazytool.entity.IEvent;
import com.jin.lazytool.entity.LoopEndEvent;
import com.jin.lazytool.task.JinTaskGroup;
import com.jin.lazytool.utils.JinUtils;
import javafx.collections.FXCollections;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;

import java.util.ArrayList;

public class CustomLoopEndEvent extends CustomEvent{


    private final ChoiceBox<String> loopNum = new ChoiceBox<>();

    @Override
    public String getName() {
        return "循环结束";
    }

    @Override
    public void initAddPanel(GridPane grid) {
        loopNum.setItems(FXCollections.observableList(CustomEvent.getNoOverLoopEvent()));
        grid.addRow(2,new Label("循环编号"),loopNum);
    }

    @Override
    public void initEditPanel(GridPane grid, IEvent event) {

    }

    @Override
    public IEvent fullAddIEvent( ) {
        LoopEndEvent loopEvent = new LoopEndEvent();
        if(loopNum.getValue() == null || "".equals(loopNum.getValue())){
            JinUtils.error("循环编号不能为空");
        }
        loopEvent.setLoopNum(loopNum.getValue());
        return loopEvent;
    }

    @Override
    public void fullEditIEvent() {

    }

    @Override
    public Class<? extends IEvent> eventClass() {
        return LoopEndEvent.class;
    }

}
